package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsDocFileTemplet;
import com.bestow.basic.service.IHlsDocFileTempletService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 文件模板Controller
 * 
 * @author liliu
 * @date 2022-09-13
 */
@RestController
@RequestMapping("/basic/docFileTemplet")
public class HlsDocFileTempletController extends BaseController
{
    @Autowired
    private IHlsDocFileTempletService hlsDocFileTempletService;

    /**
     * 查询文件模板列表
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsDocFileTemplet hlsDocFileTemplet)
    {
        startPage();
        List<HlsDocFileTemplet> list = hlsDocFileTempletService.selectHlsDocFileTempletList(hlsDocFileTemplet);
        return getDataTable(list);
    }

    /**
     * 导出文件模板列表
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:export')")
    @Log(title = "文件模板", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsDocFileTemplet hlsDocFileTemplet)
    {
        List<HlsDocFileTemplet> list = hlsDocFileTempletService.selectHlsDocFileTempletList(hlsDocFileTemplet);
        ExcelUtil<HlsDocFileTemplet> util = new ExcelUtil<HlsDocFileTemplet>(HlsDocFileTemplet.class);
        util.exportExcel(response, list, "文件模板数据");
    }

    /**
     * 获取文件模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:query')")
    @GetMapping(value = "/{templetId}")
    public AjaxResult getInfo(@PathVariable("templetId") Long templetId)
    {
        return AjaxResult.success(hlsDocFileTempletService.selectHlsDocFileTempletByTempletId(templetId));
    }

    /**
     * 新增文件模板
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:add')")
    @Log(title = "文件模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsDocFileTemplet hlsDocFileTemplet)
    {
        return toAjax(hlsDocFileTempletService.insertHlsDocFileTemplet(hlsDocFileTemplet));
    }

    /**
     * 修改文件模板
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:edit')")
    @Log(title = "文件模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsDocFileTemplet hlsDocFileTemplet)
    {
        return toAjax(hlsDocFileTempletService.updateHlsDocFileTemplet(hlsDocFileTemplet));
    }

    /**
     * 删除文件模板
     */
    @PreAuthorize("@ss.hasPermi('basic:docFileTemplet:remove')")
    @Log(title = "文件模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{templetIds}")
    public AjaxResult remove(@PathVariable Long[] templetIds)
    {
        return toAjax(hlsDocFileTempletService.deleteHlsDocFileTempletByTempletIds(templetIds));
    }
}
